import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '父目录id',
    align: 'center',
    dataIndex: 'pid'
  },
  {
    title: '名称',
    align: 'left',
    dataIndex: 'name'
  },
  {
    title: '目录',
    align: 'center',
    dataIndex: 'path'
  },
  {
    title: '目录类型',
    align: 'center',
    dataIndex: 'type_dictText'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "父目录id",
    field: "pid",
    component: 'Input',
    colProps: {span: 6},
  },
  {
    label: "目录",
    field: "path",
    component: 'Input',
    colProps: {span: 6},
  },
  {
    label: "目录类型",
    field: "type",
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "network_path_type"
    },
    colProps: {span: 6},
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '父目录id',
    field: 'pid',
    component: 'JTreeSelect',
    componentProps: {
      dict: "network_path,name,id",
      pidField: "pid",
      pidValue: "0",
      hasChildField: "has_child",
    },
    dynamicRules: () => {
      return [
        {required: true, message: '请输入父目录id!'},
      ];
    },
  },
  {
    label: '目录类型',
    field: 'type',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: "network_path_type"
    },
    dynamicRules: ({}) => {
      return [
        {required: true, message: '请输入目录类型!'},
      ];
    },
  },
  {
    label: '名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model}) => {
      return [
        {required: model.type == "folder", message: '请输入名称!'},
      ];
    },
    show: ({model}) => {
      return model.type == "folder";
    },
  },
  {
    label: '文件',
    field: 'fileUrl',
    component: 'JUpload',
    componentProps: {},
    dynamicRules: ({model}) => {
      return [
        {required: model.type == "file", message: '请先上传文件!'},
      ];
    },
    show: ({model}) => {
      return model.type == "file";
    },
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];


/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
